package cn.jjxx.modules.portal.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author mali
 */
public class PortalTalentBank implements Serializable {

    private static final long serialVersionUID = -9106321671270335382L;
    private String id;
    /**姓名*/
    private String name;
    /**性别*/
    private String sex;
    /**学历*/
    private String education;
    /**工作技能*/
    private String workSkills;
    /**联系电话*/
    private String phone;
    /**家庭住址*/
    private String familyAddress;
    /**就业意向*/
    private String workIntention;
    @JsonIgnore
    private String idcard;
    private Integer age;
    private Integer poor;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getEducation() {
        return education;
    }

    public void setEducation(String education) {
        this.education = education;
    }

    public String getWorkSkills() {
        return workSkills;
    }

    public void setWorkSkills(String workSkills) {
        this.workSkills = workSkills;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getFamilyAddress() {
        return familyAddress;
    }

    public void setFamilyAddress(String familyAddress) {
        this.familyAddress = familyAddress;
    }

    public String getWorkIntention() {
        return workIntention;
    }

    public void setWorkIntention(String workIntention) {
        this.workIntention = workIntention;
    }

    public String getIdcard() {
        return idcard;
    }

    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }

    public Integer getAge() {
        if (StringUtils.isNotBlank(this.idcard)) {
            int length = this.idcard.length();
            String dates = "";
            if (length == 18) {
                dates = this.idcard.substring(6, 10);
                SimpleDateFormat df = new SimpleDateFormat("yyyy");
                String year = df.format(new Date());
                this.age = Integer.parseInt(year) - Integer.parseInt(dates);
            } else {
                if (length == 15) {
                    dates = this.idcard.substring(6, 8);
                    this.age = Integer.parseInt(dates);
                } else {
                    this.age = 0;
                }
            }
        }
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Integer getPoor() {
        return poor;
    }

    public void setPoor(Integer poor) {
        this.poor = poor;
    }
}
